#!/bin/bash
echo "输入要备份文件路径"
read SYSTEM_DIR
echo "输入目的路径"
read BACKUP_DIR
w=0
[ -z ${SYSTEM_DIR} ]&& w=1
if [ $w -eq 1 ]; then
   echo "输入路径不能为空"
exit 0
fi
if [ ! -d $SYSTEM_DIR ]
  then
  echo "输入路径不存在"
fi
unset w
w=0
[ -z ${BACKUP_DIR} ] && w=1
if [ $w -eq 1 ]; then
  echo "输入路径不能为空"
exit 0
fi
if [ ! -d $BACKUP_DIR ]
   then
   echo "输入路径不存在"
fi
echo "start tar................."
DATE=`date +%Y%m%d%H%M%S`
if [ -f ${BACKUP_DIR}/${DATE}.TAR.GZ ]; then
   echo "\"date +%Y-%m-%d-%H-%M-%S\"的备份文件已存在"
else
   tar -czf ${BACKUP_DIR}/${DATE}.tar.gz ${SYSTEM_DIR} 2>/dev/null
fi
echo "备份结束"